{include file="common/header" /}
<style type="text/css">
    .del{
        font-weight: 600;
    }

    .img-item {
        position: relative;
        width: 80px;
        /*height: 96px;*/
        border-radius: 6px;
        margin-bottom: 10px;
        margin-right: 10px;
    }
    .img-item img {
        border-radius: 6px;
        width: 100%;
        height: 100%;
    }
    .img-item i {
        font-size: 20px;
        position: absolute;
        top: -10px;
        right: -10px;
        cursor: pointer;
    }
    .inp-img{
        width: 100%;
        height: 20px;
        padding: 3px;
        margin-top: 5px;
    }
</style>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>系统设置</legend>
            <div style="margin: 10px 10px 10px 10px">
                
                <div class="layui-tab" lay-filter="test-hash">
                  <ul class="layui-tab-title">
                    <li class="layui-this" lay-id="11">基本设置</li>
                    <li lay-id="22">附件设置</li>
                    {if session("admin_id") == 1 /}
                    <li lay-id="33">支付宝设置</li>
                    <li lay-id="44">微信支付设置</li>
                    <li lay-id="55">增加新变量</li>
                    {/if}
                  </ul>
                  <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        
                        <form action="{:url('admin/webconfig/system')}" method="post" class="form-horizontal layui-form">
                            {volist name="res2" id="vo"}
                                {if condition="$vo['vargroup'] == 0 "}
                                    <?php if($vo['vartype'] == 'string'){?>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label required">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                                <input type="text" class="layui-input" name="{$vo.varname}" value="{$vo.varvalue}" autocomplete="off" >
                                            </div>
                                            {if session("admin_id") == 1  /}
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                            {/if}
                                        </div>
                                    <?php }else if($vo['vartype'] == 'number'){?>
                                        <div class="layui-form-item layui-form-text">
                                            <label class="layui-form-label">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                              <input type="number" class="layui-input" name="{$vo.varname}" value="{$vo.varvalue}" autocomplete="off" >
                                            </div>
                                            {if session("admin_id") == 1  /}
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                            {/if}
                                        </div>
                                    <?php }else if($vo['vartype'] == 'bstring'){?>
                                        <div class="layui-form-item layui-form-text">
                                            <label class="layui-form-label">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                              <textarea name="{$vo.varname}" class="layui-textarea">{$vo.varvalue}</textarea>
                                            </div>
                                            {if session("admin_id") == 1  /}
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                            {/if}
                                        </div>
                                    <?php }else if($vo['vartype'] == 'bool'){?>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                              <input type="radio" name="{$vo.varname}" {if condition="$vo.varvalue == 'Y'" }checked{/if} value="Y" title="Y">
                                              <input type="radio" name="{$vo.varname}" {if condition="$vo.varvalue == 'N'" }checked{/if} value="N" title="N">
                                            </div>
                                            {if session("admin_id") == 1  /}
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                            {/if}
                                        </div>
                                    <?php }else if($vo['vartype'] == 'image'){?>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label required">{$vo.varinfo}</label>
                                            <div class="layui-input-inline">
                                                <button type="button" class="layui-btn" id="{$vo.varname}_image_up">
                                                  <i class="layui-icon layui-icon-upload"></i> 图片上传
                                                </button>
                                                
                                                <div class="pic" id="{$vo.varname}_image_show" style="margin-top:10px;"> 
                                                    {if $vo.varvalue /}
                                                        <div class="img-item">
                                                            <a href="{$vo.varvalue}" target="_blank">
                                                                <img data-url="{$vo.varvalue}" src="{$vo.varvalue}" alt="">
                                                            </a>
                                                            <i  class="layui-icon layui-icon-close-fill" onclick="imgdelete(this)"></i>
                                                            <input type="text" class="inp-img" name="{$vo.varname}" value="{$vo.varvalue}" >
                                                        </div>
                                                    {/if}
                                                </div>
                                                    
                                                
                                            </div>
                                            {if session("admin_id") == 1  /}
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                            {/if}
                                        </div>
                                        <script type="text/javascript">
                                            
                                            layui.use(['form', 'table','element','upload'], function () {
                                                var $ = layui.jquery,
                                                    form = layui.form,
                                                    table = layui.table,
                                                    upload = layui.upload,
                                                    layuimini = layui.layuimini;
                                                var element = layui.element;
                                                upload.render({
                                                    elem: '#{$vo["varname"]}_image_up'
                                                    ,url: "{:url('Index/dyupload')}" 
                                                    // ,multiple: true
                                                    //,accept: 'file' //普通文件
                                                    ,field: 'dypic'
                                                    ,before: function(obj){
                                                    }
                                                    ,done: function(res){
                                                      if(res.errcode){
                                                        var html = '';
                                                        html +='<div class="img-item">';
                                                        if(res.count == 'file'){
                                                            html +='    <a href="'+ res.data +'" target="_blank"><img data-url="'+res.data+'" src="/public/static/images/pdf.png" alt=""></a>';
                                                        }else{
                                                            html +='    <a href="'+ res.data +'" target="_blank"><img data-url="'+res.data+'" src="'+ res.data +'" alt=""></a>';
                                                        }
                                                        html +='    <i  class="layui-icon layui-icon-close-fill" onclick="imgdelete(this)"></i>';

                                                        html +='<input type="text" class="inp-img" name="{$vo.varname}" value="'+ res.data +'" >';
                                                        html +='</div>';
                                                        
                                                        $('#{$vo.varname}_image_show').html(html)
                                                      }
                                                    }
                                                });

                                            });

                                        </script>

                                    <?php }?>
                                {/if}
                            {/volist}

                            
                                    
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <!-- <button type="submit" class="layui-btn">保存内容</button> -->
                                    <button type="button" class="layui-btn" lay-submit lay-filter="saveBtn">保存内容</button>
                                </div>
                            </div>
                        </form>


                    </div>






                    <div class="layui-tab-item">
                        <!-- 内容-2 -->
                        <form action="{:url('admin/webconfig/system')}" method="post" class="form-horizontal layui-form">
                            {volist name="res" id="vo"}
                                {if condition="$vo['vargroup'] == 1 "}
                                    <?php if($vo['vartype'] == 'string'){?>

                                        {if session("admin_id") != 1 /}
                                            {if !($vo.varname =='cfg_upload_img_type' || $vo.varname =='cfg_upload_soft_type' || $vo.varname =='cfg_upload_media_type') /}
                                            <div class="layui-form-item">
                                                <label class="layui-form-label required">{$vo.varinfo}</label>
                                                <div class="layui-input-inline" style="width: 60%;">
                                                    <input type="text" class="layui-input" name="{$vo.varname}" value="{$vo.varvalue}" autocomplete="off" >
                                                </div>
                                                {if session("admin_id") == 1  /}
                                                <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                                {/if}
                                            </div>
                                            {/if}
                                        {else/}
                                            <div class="layui-form-item">
                                                <label class="layui-form-label required">{$vo.varinfo}</label>
                                                <div class="layui-input-inline" style="width: 60%;">
                                                    <input type="text" class="layui-input" name="{$vo.varname}" value="{$vo.varvalue}" autocomplete="off" >
                                                </div>
                                                {if session("admin_id") == 1  /}
                                                <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                                {/if}
                                            </div>
                                        {/if}
                                    <?php }else if($vo['vartype'] == 'number'){?>
                                        <div class="layui-form-item layui-form-text">
                                            <label class="layui-form-label">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                              <input type="number" class="layui-input" name="{$vo.varname}" value="{$vo.varvalue}" autocomplete="off" >
                                            </div>
                                            {if session("admin_id") == 1  /}
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                            {/if}
                                        </div>
                                    <?php }else if($vo['vartype'] == 'bstring'){?>
                                        <div class="layui-form-item layui-form-text">
                                            <label class="layui-form-label">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                              <textarea name="{$vo.varname}" class="layui-textarea">{$vo.varvalue}</textarea>
                                            </div>
                                            {if session("admin_id") == 1  /}
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                            {/if}
                                        </div>
                                    <?php }else if($vo['vartype'] == 'bool'){?>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                              <input type="radio" name="{$vo.varname}" {if condition="$vo.varvalue == 'Y'" }checked{/if} value="Y" title="Y">
                                              <input type="radio" name="{$vo.varname}" {if condition="$vo.varvalue == 'N'" }checked{/if} value="N" title="N">
                                            </div>
                                            {if session("admin_id") == 1  /}
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                            {/if}
                                        </div>
                                    <?php }else if($vo['vartype'] == 'image'){?>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label required">{$vo.varinfo}</label>
                                            <div class="layui-input-inline">
                                                <button type="button" class="layui-btn" id="{$vo.varname}_image_up">
                                                  <i class="layui-icon layui-icon-upload"></i> 图片上传
                                                </button>
                                                
                                                <div class="pic" id="{$vo.varname}_image_show" style="margin-top:10px;"> 
                                                    {if $vo.varvalue /}
                                                        <div class="img-item">
                                                            <a href="{$vo.varvalue}" target="_blank">
                                                                <img data-url="{$vo.varvalue}" src="{$vo.varvalue}" alt="">
                                                            </a>
                                                            <i  class="layui-icon layui-icon-close-fill" onclick="imgdelete(this)"></i>
                                                            <input type="text" class="inp-img" name="{$vo.varname}" value="{$vo.varvalue}" >
                                                        </div>
                                                    {/if}
                                                </div>
                                                    
                                                
                                            </div>
                                            {if session("admin_id") == 1  /}
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                            {/if}
                                        </div>
                                        <script type="text/javascript">
                                            
                                            layui.use(['form', 'table','element','upload'], function () {
                                                var $ = layui.jquery,
                                                    form = layui.form,
                                                    table = layui.table,
                                                    upload = layui.upload,
                                                    layuimini = layui.layuimini;
                                                var element = layui.element;
                                                upload.render({
                                                    elem: '#{$vo["varname"]}_image_up'
                                                    ,url: "{:url('Index/dyupload')}" 
                                                    // ,multiple: true
                                                    //,accept: 'file' //普通文件
                                                    ,field: 'dypic'
                                                    ,before: function(obj){
                                                    }
                                                    ,done: function(res){
                                                      if(res.errcode){
                                                        var html = '';
                                                        html +='<div class="img-item">';
                                                        if(res.count == 'file'){
                                                            html +='    <a href="'+ res.data +'" target="_blank"><img data-url="'+res.data+'" src="/public/static/images/pdf.png" alt=""></a>';
                                                        }else{
                                                            html +='    <a href="'+ res.data +'" target="_blank"><img data-url="'+res.data+'" src="'+ res.data +'" alt=""></a>';
                                                        }
                                                        html +='    <i  class="layui-icon layui-icon-close-fill" onclick="imgdelete(this)"></i>';

                                                        html +='<input type="text" class="inp-img" name="{$vo.varname}" value="'+ res.data +'" >';
                                                        html +='</div>';
                                                        
                                                        $('#{$vo.varname}_image_show').html(html)
                                                      }
                                                    }
                                                });

                                            });

                                        </script>
                                    <?php }?>
                                {/if}
                            {/volist}
                                    
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button type="button" class="layui-btn" lay-submit lay-filter="saveBtn">保存内容</button>
                                </div>
                            </div>
                        </form>
                    </div>


                    <div class="layui-tab-item">
                        <!-- 支付宝设置-->
                        <form action="{:url('admin/webconfig/system')}" method="post" class="form-horizontal layui-form">
                            {volist name="res" id="vo"}
                                {if condition="$vo['vargroup'] == 6 "}
                                    <?php if($vo['vartype'] == 'string'){?>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label required">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                                <input type="text" class="layui-input" name="{$vo.varname}" value="{$vo.varvalue}" autocomplete="off" >
                                            </div>
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                        </div>
                                    <?php }else if($vo['vartype'] == 'number'){?>
                                        <div class="layui-form-item layui-form-text">
                                            <label class="layui-form-label">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                              <input type="number" class="layui-input" name="{$vo.varname}" value="{$vo.varvalue}" autocomplete="off" >
                                            </div>
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                        </div>
                                    <?php }else if($vo['vartype'] == 'bstring'){?>
                                        <div class="layui-form-item layui-form-text">
                                            <label class="layui-form-label">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                              <textarea name="{$vo.varname}" class="layui-textarea">{$vo.varvalue}</textarea>
                                            </div>
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                        </div>
                                    <?php }else if($vo['vartype'] == 'bool'){?>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                              <input type="radio" name="{$vo.varname}" {if condition="$vo.varvalue == 'Y'" }checked{/if} value="Y" title="Y">
                                              <input type="radio" name="{$vo.varname}" {if condition="$vo.varvalue == 'N'" }checked{/if} value="N" title="N">
                                            </div>
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                        </div>
                                    <?php }else if($vo['vartype'] == 'image'){?>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label required">{$vo.varinfo}</label>
                                            <div class="layui-input-inline">
                                                <button type="button" class="layui-btn" id="{$vo.varname}_image_up">
                                                  <i class="layui-icon layui-icon-upload"></i> 图片上传
                                                </button>
                                                
                                                <div class="pic" id="{$vo.varname}_image_show" style="margin-top:10px;"> 
                                                    {if $vo.varvalue /}
                                                        <div class="img-item">
                                                            <a href="{$vo.varvalue}" target="_blank">
                                                                <img data-url="{$vo.varvalue}" src="{$vo.varvalue}" alt="">
                                                            </a>
                                                            <i  class="layui-icon layui-icon-close-fill" onclick="imgdelete(this)"></i>
                                                            <input type="text" class="inp-img" name="{$vo.varname}" value="{$vo.varvalue}" >
                                                        </div>
                                                        
                                                    {/if}
                                                </div>
                                                    
                                                
                                            </div>
                                            {if session("admin_id") == 1  /}
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                            {/if}
                                        </div>
                                        <script type="text/javascript">
                                            
                                            layui.use(['form', 'table','element','upload'], function () {
                                                var $ = layui.jquery,
                                                    form = layui.form,
                                                    table = layui.table,
                                                    upload = layui.upload,
                                                    layuimini = layui.layuimini;
                                                var element = layui.element;
                                                upload.render({
                                                    elem: '#{$vo["varname"]}_image_up'
                                                    ,url: "{:url('Index/dyupload')}" 
                                                    // ,multiple: true
                                                    //,accept: 'file' //普通文件
                                                    ,field: 'dypic'
                                                    ,before: function(obj){
                                                    }
                                                    ,done: function(res){
                                                      if(res.errcode){
                                                        var html = '';
                                                        html +='<div class="img-item">';
                                                        if(res.count == 'file'){
                                                            html +='    <a href="'+ res.data +'" target="_blank"><img data-url="'+res.data+'" src="/public/static/images/pdf.png" alt=""></a>';
                                                        }else{
                                                            html +='    <a href="'+ res.data +'" target="_blank"><img data-url="'+res.data+'" src="'+ res.data +'" alt=""></a>';
                                                        }
                                                        html +='    <i  class="layui-icon layui-icon-close-fill" onclick="imgdelete(this)"></i>';

                                                        html +='<input type="text" class="inp-img" name="{$vo.varname}" value="'+ res.data +'" >';
                                                        html +='</div>';
                                                        
                                                        $('#{$vo.varname}_image_show').html(html)
                                                      }
                                                    }
                                                });

                                            });

                                        </script>
                                    <?php }?>
                                {/if}
                            {/volist}
                                    
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button type="button" class="layui-btn" lay-submit lay-filter="saveBtn">保存内容</button>
                                </div>
                            </div>
                        </form>
                    </div>


                    <div class="layui-tab-item">
                        <!-- 微信支付设置 -->
                        <form action="{:url('admin/webconfig/system')}" method="post" class="form-horizontal layui-form">
                            {volist name="res" id="vo"}
                                {if condition="$vo['vargroup'] == 7 "}
                                    <?php if($vo['vartype'] == 'string'){?>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label required">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                                <input type="text" class="layui-input" name="{$vo.varname}" value="{$vo.varvalue}" autocomplete="off" >
                                            </div>
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                        </div>
                                    <?php }else if($vo['vartype'] == 'number'){?>
                                        <div class="layui-form-item layui-form-text">
                                            <label class="layui-form-label">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                              <input type="number" class="layui-input" name="{$vo.varname}" value="{$vo.varvalue}" autocomplete="off" >
                                            </div>
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                        </div>
                                    <?php }else if($vo['vartype'] == 'bstring'){?>
                                        <div class="layui-form-item layui-form-text">
                                            <label class="layui-form-label">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                              <textarea name="{$vo.varname}" class="layui-textarea">{$vo.varvalue}</textarea>
                                            </div>
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                        </div>
                                    <?php }else if($vo['vartype'] == 'bool'){?>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">{$vo.varinfo}</label>
                                            <div class="layui-input-inline" style="width: 60%;">
                                              <input type="radio" name="{$vo.varname}" {if condition="$vo.varvalue == 'Y'" }checked{/if} value="Y" title="Y">
                                              <input type="radio" name="{$vo.varname}" {if condition="$vo.varvalue == 'N'" }checked{/if} value="N" title="N">
                                            </div>
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                        </div>
                                    <?php }else if($vo['vartype'] == 'image'){?>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label required">{$vo.varinfo}</label>
                                            <div class="layui-input-inline">
                                                <button type="button" class="layui-btn" id="{$vo.varname}_image_up">
                                                  <i class="layui-icon layui-icon-upload"></i> 图片上传
                                                </button>
                                                
                                                <div class="pic" id="{$vo.varname}_image_show" style="margin-top:10px;"> 
                                                    {if $vo.varvalue /}
                                                        <div class="img-item">
                                                            <a href="{$vo.varvalue}" target="_blank">
                                                                <img data-url="{$vo.varvalue}" src="{$vo.varvalue}" alt="">
                                                            </a>
                                                            <i  class="layui-icon layui-icon-close-fill" onclick="imgdelete(this)"></i>
                                                            <input type="text" class="inp-img" name="{$vo.varname}" value="{$vo.varvalue}" >
                                                        </div>
                                                        
                                                    {/if}
                                                </div>
                                                    
                                                
                                            </div>
                                            {if session("admin_id") == 1  /}
                                            <div class="layui-form-mid layui-text-em">排序：{$vo.orderid}<a class="del" data-varname="{$vo.varname}" href="javascript:;"> 删除</a> <span>{$vo.varname}</span></div>
                                            {/if}
                                        </div>
                                        <script type="text/javascript">
                                            
                                            layui.use(['form', 'table','element','upload'], function () {
                                                var $ = layui.jquery,
                                                    form = layui.form,
                                                    table = layui.table,
                                                    upload = layui.upload,
                                                    layuimini = layui.layuimini;
                                                var element = layui.element;
                                                upload.render({
                                                    elem: '#{$vo["varname"]}_image_up'
                                                    ,url: "{:url('Index/dyupload')}" 
                                                    // ,multiple: true
                                                    //,accept: 'file' //普通文件
                                                    ,field: 'dypic'
                                                    ,before: function(obj){
                                                    }
                                                    ,done: function(res){
                                                      if(res.errcode){
                                                        var html = '';
                                                        html +='<div class="img-item">';
                                                        if(res.count == 'file'){
                                                            html +='    <a href="'+ res.data +'" target="_blank"><img data-url="'+res.data+'" src="/public/static/images/pdf.png" alt=""></a>';
                                                        }else{
                                                            html +='    <a href="'+ res.data +'" target="_blank"><img data-url="'+res.data+'" src="'+ res.data +'" alt=""></a>';
                                                        }
                                                        html +='    <i  class="layui-icon layui-icon-close-fill" onclick="imgdelete(this)"></i>';

                                                        html +='<input type="text" class="inp-img" name="{$vo.varname}" value="'+ res.data +'" >';
                                                        html +='</div>';
                                                        
                                                        $('#{$vo.varname}_image_show').html(html)
                                                      }
                                                    }
                                                });

                                            });

                                        </script>
                                    <?php }?>
                                {/if}
                            {/volist}
                                    
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button type="button" class="layui-btn" lay-submit lay-filter="saveBtn">保存内容</button>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="layui-tab-item">
                        <!-- 内容-4 -->
                        <form action="{:url('admin/system/addSystem')}" method="post" class="form-horizontal layui-form">    
                            
                            <div class="layui-form-item">
                                <label class="layui-form-label required">变量名称</label>
                                <div class="layui-input-inline" style="width: 60%;">
                                    <input name="varname" type="text" class="layui-input" value="" required >
                                </div>
                            </div>
                            
                            <div class="layui-form-item">
                                <label class="layui-form-label required">参数说明</label>
                                <div class="layui-input-inline" style="width: 60%;">
                                    <input name="varinfo" type="text" class="layui-input" value="" required >
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label required">变量值</label>
                                <div class="layui-input-inline" style="width: 60%;">
                                    <input name="varvalue" type="text" class="layui-input" value="" required >
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label required">变量类型</label>
                                <div class="layui-input-inline" style="width: 60%;">
                                    <input type="radio" name="vartype"  value="string" title="文本" checked >
                                    <input type="radio" name="vartype"  value="number" title="数字" >
                                    <input type="radio" name="vartype"  value="bool" title=" 布尔(Y/N)" >
                                    <input type="radio" name="vartype"  value="bstring" title="多行文本" >
                                    <input type="radio" name="vartype"  value="image" title="图片" >
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label required">Select</label>
                                <div class="layui-input-inline" style="width: 60%;">
                                    <select name="vargroup" >
                                        <option value="0" selected="selected">基本设置</option>
                                        <option value="1">附件设置</option>
                                        <option value="6">支付宝设置</option>

                                        <option value="7">微信支付设置</option>
                                        
                                    </select>
                                </div>
                            </div>


                            <div class="layui-form-item">
                                <label class="layui-form-label required">排序</label>
                                <div class="layui-input-inline" style="width: 60%;">
                                    <input name="orderid" type="text" class="layui-input" value="{$sort}" required >
                                </div>
                            </div>
                            
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button type="button" class="layui-btn" lay-submit lay-filter="saveBtn2">保存内容</button>
                                </div>
                            </div>
                        </form>

                    </div>
                  </div>
                </div>

            </div>
        </fieldset>

    </div>
</div>

<script>
    layui.use(['form', 'table','element','upload'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                upload = layui.upload,
                layuimini = layui.layuimini;

            var element = layui.element;
      
              // hash 地址定位
              var hashName = 'tabid'; // hash 名称
              var layid = location.hash.replace(new RegExp('^#'+ hashName + '='), ''); // 获取 lay-id 值
                
              // 初始切换
              element.tabChange('test-hash', layid);
              // 切换事件
              element.on('tab(test-hash)', function(obj){
                location.hash = hashName +'='+ this.getAttribute('lay-id');
              });


            window.imgdelete = function(dom){
                $(dom).parent().remove();
            }
            //监听提交
            form.on('submit(saveBtn)', function (data) {
                var index = layer.load(1, {
                    shade: [0.3,'#000'] //0.1透明度的白色背景
                });
                var data = data.field;
                $.ajax({
                    url:"{:url('webconfig/system')}",
                    data:data,
                    type:'post',
                    dataType:'json',
                    success:function(res){
                        // console.log(res)
                        // return false
                        if(res.errcode != 1){
                            layer.msg(res.message,{icon: 2,time: 2000},function(){
                                layer.close(index);
                            })
                        }else{
                            layer.msg(res.message,{icon: 1,time: 1000},function () {
                                //window.location.href = "{:url('webconfig/system')}";
                                location.reload();
                            })
                        }
                        layer.close(index);
                    },
                    error : function(XMLHttpRequest, textStatus, errorThrown) {
                        layer.msg('网络失败，请刷新页面后重试!',{icon: 2,time: 2000})
                    }
                });

                return false;
            });

            form.on('submit(saveBtn2)', function (data) {
                var index = layer.load(1, {
                    shade: [0.3,'#000'] //0.1透明度的白色背景
                });
                var data = data.field;
                $.ajax({
                    url:"{:url('webconfig/addSystem')}",
                    data:data,
                    type:'post',
                    dataType:'json',
                    success:function(res){
                        // layer.close(index);
                        // console.log(res)
                        // return false
                        if(res.errcode != 1){
                            layer.msg(res.message,{icon: 2,time: 2000},function(){
                                layer.close(index);
                            })
                        }else{
                            layer.msg(res.message,{icon: 1,time: 1000},function () {
                                //window.location.href = "{:url('webconfig/system')}";
                                location.reload();
                            })
                        }
                        layer.close(index);
                    },
                    error : function(XMLHttpRequest, textStatus, errorThrown) {
                        layer.msg('网络失败，请刷新页面后重试!',{icon: 2,time: 2000})
                    }
                });

                return false;
            });

            $(".del").click(function(){
                let varname = $(this).attr("data-varname");
                layer.confirm('确认删除吗', function (index) {
                    $.ajax({
                        url:"{:url('webconfig/deleteSystem')}",
                        data: {'varname':varname},
                        type:'post',
                        dataType:'json',
                        success:function(res){
                            // console.log(res);
                            // return false
                            if(res.errcode == 1){
                                layer.msg(res.message,{icon: 1,time: 1000},function(){
                                    // obj.del(); //删除对应行（tr）的DOM结构
                                    location.reload();
                                })
                            }else {
                                layer.msg(res.message,{icon: 2,time: 2000})
                            }
                            // parent.layer.close(index);
                        },
                        error : function(XMLHttpRequest, textStatus, errorThrown) {
                            layer.msg('网络失败，请刷新页面后重试!',{icon: 2,time: 2000})
                        }
                    });

                });
            });



            table.on('tool(currentTableFilter)', function (obj) {
                var data = obj.data;
                if (obj.event === 'edit') {
                    let cate_id = $("#cate_id").val();
                    window.location.href="{:url('policy/edit')}?id="+data.id+"&cate_id="+cate_id;
                    return false;
                } else if (obj.event === 'delete') {
                    layer.confirm('确认删除吗', function (index) {
                        $.ajax({
                            url:"{:url('policy/delete')}",
                            data: {id:data.id,'table':'policy','id_name':'id'},
                            type:'post',
                            dataType:'json',
                            success:function(res){
                                // console.log(res);
                                // return false
                                if(res.errcode == 1){
                                    layer.msg(res.message,{icon: 1,time: 1000},function(){
                                        obj.del(); //删除对应行（tr）的DOM结构
                                        // location.reload();
                                    })
                                }else {
                                    layer.msg(res.message,{icon: 2,time: 2000})
                                }
                                // parent.layer.close(index);
                            },
                            error : function(XMLHttpRequest, textStatus, errorThrown) {
                                layer.msg('网络失败，请刷新页面后重试!',{icon: 2,time: 2000})
                            }
                        });

                    });
                }
            });

    });
</script>

</body>
</html>